<?php

class Halls_EditInputView extends SrsHallsBaseView
{
	public function executeHtml(AgaviRequestDataHolder $rd)
	{
		$this->setupHtml($rd);

		$hall = Doctrine_Query::create()
		        ->from('Hall')
			      ->where('id=?', $rd->getParameter('id'))
					  ->fetchOne();

		if (!$hall instanceof Hall) return $this->forward404();

		$referer = $rd->getHeader('REFERER', $this->genUrl('hall.read', array('id' => $hall['id'])));

		$form = new AgaviParameterHolder(array(
			'hall' => array(
				'name'     => $hall['name'],
				'address'  => $hall['address'],
				'capacity' => $hall['capacity'],
			),
			'referer' => $referer
		));

		$this->populate('editHall', $form);
		
		$this->setAttribute('hall', $hall);
		$this->setAttribute('referer', $referer);
	}
}